#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define ll long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define getBit(mask, k) (((mask) / pw[k]) % pw[1])
#define setBit(mask, k, l) (((mask) / pw[k + 1] * pw[1] + (l)) * pw[k] + ((mask) % pw[k]))
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define ff first
#define ss second 
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int inf = 1 << 28;
const ldb pi = fabsl(atan2l(0.0, -1.0));
using namespace std;

int n,m;
bool use[19][19];
vector <int> hehe[4];
int per[19];

void load()
{
	cin >> n >> m;
	memset(use, 0, sizeof use);
	hehe[0].resize(0);
	hehe[1].resize(0);
	hehe[2].resize(0);
	hehe[3].resize(0);
	int a, b;
	
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d", &a, &b);
		use[a][b] = 1;
		use[b][a] = 1;
	}
	for (int i = 1; i <= n; i++)
	{
		per[i] = i;
   	}
}


int count()
{
	int res = 0;
	for (int i = 0; i < 4; i++)
		{
			for (int j = i + 1; j < 4; j++)
			{
				for (int k = 0; k < hehe[i].size(); k++)
				{
					for (int l = 0; l < hehe[j].size(); l++)
					{
						if (!use[hehe[i][k]][hehe[j][l]]) continue;
							res++;                
					}
				}
			}
		}
	return res;	
}

void solve()
{
	random_shuffle(per + 1, per + n + 1);
	int k = n / 4;
	for (int i = 1; i <= k; i++)
		hehe[0].pb(per[i]);

	for (int i = 1; i <= k; i++)
		hehe[1].pb(per[k + i]);

	int d = (n - 2 * k) / 2;
	for (int i = 1; i <= d; i++)
		hehe[2].pb(per[2 * k + i]);

	for (int i = 1; i <= d; i++)
		hehe[3].pb(per[2 * k + d + i]);

	int res = count();
	bool ok = true;
	while (ok)
	{
		ok = false;
		for (int i = 0; i < 4; i++)
		{
			for (int j = i + 1; j < 4; j++)
			{
				for (int k = 0; k < hehe[i].size(); k++)
				{
					for (int l = 0; l < hehe[j].size(); l++)
					{
						swap(hehe[i][k], hehe[j][l]);
						if (count() < res)
						{
							res = count();
							ok = true;
						}
						else 
							swap(hehe[i][k], hehe[j][l]);
					}
				}
		   	}
		}
	}
	cout << res << "\n";
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < hehe[i].size(); j++)
		{
			if (i == 0)
				printf("-%d %d\n", (j + 1), (j + 1));
			else if (i == 1)
				printf("%d %d\n", (j + 1), (j + 1));	
			else if (i == 2)
				printf("%d -%d\n", (j + 1), (j + 1));
			else printf("-%d -%d\n", (j + 1), (j + 1));
		}
	}
}

#define file "graph"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
	#endif
	int T;
	cin >> T;
	for (int i = 0; i < T; i++)
	{
		load();
		solve();
	}
	return 0;
}

